
import {Global, Module} from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import {ConfigService} from "@nestjs/config";
import {WebAuthStrategy} from "./web-auth.strategies";
import {WebUserModule} from "../user/web-user.module";
import {PassportModule} from "@nestjs/passport";
import {WebAuthController} from "./web-auth-controller";
import {WebAuthService} from "./web-auth.service";


@Global()
@Module({
    imports: [
        WebUserModule,
        PassportModule.register({ defaultStrategy: 'jwt-web' }),
        JwtModule.registerAsync({
            useFactory: async (configService:ConfigService) => ({
                secret: configService.get('web.jwt.secretKey'),
                signOptions:{
                    expiresIn: configService.get('web.jwt.expiresIn')
                }
            }),
            inject: [ConfigService]
        }),
    ],
    controllers : [WebAuthController],
    providers: [WebAuthStrategy,WebAuthService],
    exports : [WebAuthService],
})
export class WebAuthModule {}
